package com.ouc.dcrms.video;

import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;

import java.awt.Component;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.BorderFactory;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import javax.swing.ListCellRenderer;
import javax.swing.SwingConstants;
import javax.swing.WindowConstants;

/*****************************************************************************
 * 类 ： JDialogUserConfig 
 * 类描述 ：用户参数配置
 ****************************************************************************/
public class JDialogUserConfig extends JDialog {
    
    private static final long serialVersionUID = 121312310000L;
    
    static HCNetSDK hCNetSDK = HCNetSDK.INSTANCE;
    private NativeLong m_lUserID;// 用户ID
    private HCNetSDK.NET_DVR_DEVICEINFO_V30 m_strDeviceInfo;// 设备信息
    private HCNetSDK.NET_DVR_IPPARACFG m_strIpparaCfg;// IP参数
    private HCNetSDK.NET_DVR_USER_V30 m_struUserCfg;// 用户参数
    private CheckListItem m_LocalChannel[] = new CheckListItem[HCNetSDK.MAX_CHANNUM_V30];// 本地list里对应Checkbox的值
    private CheckListItem m_RemoteChannel[] = new CheckListItem[HCNetSDK.MAX_CHANNUM_V30];// 远程list里对应Checkbox的值
    private int m_iUserIndex;// 用户数组下标
    private boolean bInitialed;// Dialog是否已初始化

    /*************************************************
     * 函数: JDialogUserConfig 
     * 函数描述: 构造函数 Creates new form JDialogUserConfig
     *************************************************/
    public JDialogUserConfig(java.awt.Frame parent, boolean modal,
	    NativeLong lUserID, HCNetSDK.NET_DVR_DEVICEINFO_V30 strDeviceInfo,
	    HCNetSDK.NET_DVR_IPPARACFG strIpparaCfg) {
	super(parent, modal);
	initComponents();

	m_strDeviceInfo = strDeviceInfo;
	m_strIpparaCfg = strIpparaCfg;
	m_lUserID = lUserID;

	// 初始化对话框
	initialDialog();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed"
    // desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

	jPanel1 = new JPanel();
	jLabel1 = new JLabel();
	jLabel2 = new JLabel();
	jComboBoxPriority = new JComboBox<Object>();
	jLabel3 = new JLabel();
	jLabel4 = new JLabel();
	jComboBoxUser = new JComboBox<Object>();
	jLabel5 = new JLabel();
	jTextFieldUserIP = new JTextField();
	jTextFieldUserName = new JTextField();
	jLabel6 = new JLabel();
	jPasswordFieldPassConfirm = new JPasswordField();
	jPasswordFieldPassword = new JPasswordField();
	jLabel7 = new JLabel();
	jTextFieldMac1 = new JTextField();
	jTextFieldMac2 = new JTextField();
	jTextFieldMac3 = new JTextField();
	jTextFieldMac4 = new JTextField();
	jTextFieldMac5 = new JTextField();
	jTextFieldMac6 = new JTextField();
	jLabel9 = new JLabel();
	jLabel10 = new JLabel();
	jLabel11 = new JLabel();
	jLabel12 = new JLabel();
	jLabel13 = new JLabel();
	jPanelLocal = new JPanel();
	jCheckBoxLocalPlayback = new JCheckBox();
	jCheckBoxLoacalRecord = new JCheckBox();
	jCheckBoxLocalPTZ = new JCheckBox();
	jCheckBoxLocalBackup = new JCheckBox();
	jCheckBoxLocalState = new JCheckBox();
	jCheckBoxLocalUpdate = new JCheckBox();
	jCheckBoxLocalSetPara = new JCheckBox();
	jCheckBoxLocalIPCamera = new JCheckBox();
	jCheckBoxLocalReboot = new JCheckBox();
	jSeparator1 = new JSeparator();
	jLabel8 = new JLabel();
	jComboBoxLocal = new JComboBox<Object>();
	jScrollPane1 = new JScrollPane();
	jListLocal = new JList<CheckListItem>();
	jButtonSaveLocal = new JButton();
	jPanelRemote = new JPanel();
	jCheckBoxRemotePlayback = new JCheckBox();
	jCheckBoxRemoteRealplay = new JCheckBox();
	jCheckBoxRemoteRecord = new JCheckBox();
	jCheckBoxRemotePTZ = new JCheckBox();
	jCheckBoxRemoteState = new JCheckBox();
	jCheckBoxRemoteUpdate = new JCheckBox();
	jCheckBoxRemoteSerial = new JCheckBox();
	jCheckBoxRemoteAlarm = new JCheckBox();
	jCheckBoxRemoteSetPara = new JCheckBox();
	jCheckBoxRemoteVoice = new JCheckBox();
	jCheckBoxRemoteControl = new JCheckBox();
	jCheckBoxRemoteIPCamera = new JCheckBox();
	jCheckBoxRemoteReboot = new JCheckBox();
	jSeparator2 = new JSeparator();
	jScrollPane2 = new JScrollPane();
	jListRemote = new JList<CheckListItem>();
	jLabel14 = new JLabel();
	jComboBoxRemote = new JComboBox<Object>();
	jButtonSaveRemote = new JButton();
	jButtonSaveUser = new JButton();
	jButtonSetup = new JButton();
	jButtonExit = new JButton();
	jButtonUPdate = new JButton();

	setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	setTitle("用户配置");

	jPanel1.setBorder(BorderFactory.createTitledBorder(""));
	jPanel1.setForeground(new java.awt.Color(0, 70, 213));
	jPanel1.setLayout(null);

	jLabel1.setText("用户");
	jPanel1.add(jLabel1);
	jLabel1.setBounds(20, 20, 24, 15);

	jLabel2.setText("优先级");
	jPanel1.add(jLabel2);
	jLabel2.setBounds(20, 50, 36, 15);

	jComboBoxPriority.setModel(new DefaultComboBoxModel<Object>(
		new String[] { "普通用户", "操作员", "管理员" }));
	jPanel1.add(jComboBoxPriority);
	jComboBoxPriority.setBounds(80, 50, 80, 20);

	jLabel3.setText("用户名称");
	jPanel1.add(jLabel3);
	jLabel3.setBounds(180, 20, 50, 15);

	jLabel4.setText("允许IP");
	jPanel1.add(jLabel4);
	jLabel4.setBounds(180, 50, 36, 15);

	jComboBoxUser.setModel(new DefaultComboBoxModel<Object>(new String[] {
		"超级用户", "用户1", "用户2", "用户3", "用户4", "用户5", "用户6", "用户7", "用户8",
		"用户9", "用户10", "用户11", "用户12", "用户13", "用户14", "用户15", "用户16",
		"用户17", "用户18", "用户19", "用户20", "用户21", "用户22", "用户23", "用户24",
		"用户25", "用户26", "用户27", "用户28", "用户29", "用户30", "用户31" }));
	jComboBoxUser.addActionListener(new java.awt.event.ActionListener() {
	    public void actionPerformed(java.awt.event.ActionEvent evt) {
		jComboBoxUserActionPerformed(evt);
	    }
	});
	jPanel1.add(jComboBoxUser);
	jComboBoxUser.setBounds(80, 20, 80, 20);

	jLabel5.setText("密码");
	jPanel1.add(jLabel5);
	jLabel5.setBounds(340, 20, 24, 15);
	jPanel1.add(jTextFieldUserIP);
	jTextFieldUserIP.setBounds(240, 50, 80, 21);
	jPanel1.add(jTextFieldUserName);
	jTextFieldUserName.setBounds(240, 20, 80, 21);

	jLabel6.setText("确认密码");
	jPanel1.add(jLabel6);
	jLabel6.setBounds(450, 20, 50, 15);
	jPanel1.add(jPasswordFieldPassConfirm);
	jPasswordFieldPassConfirm.setBounds(510, 20, 80, 21);
	jPanel1.add(jPasswordFieldPassword);
	jPasswordFieldPassword.setBounds(370, 20, 70, 21);

	jLabel7.setText("允许物理地址");
	jPanel1.add(jLabel7);
	jLabel7.setBounds(340, 50, 80, 15);
	jPanel1.add(jTextFieldMac1);
	jTextFieldMac1.setBounds(420, 50, 20, 21);
	jPanel1.add(jTextFieldMac2);
	jTextFieldMac2.setBounds(450, 50, 20, 21);
	jPanel1.add(jTextFieldMac3);
	jTextFieldMac3.setBounds(480, 50, 20, 21);
	jPanel1.add(jTextFieldMac4);
	jTextFieldMac4.setBounds(510, 50, 20, 21);
	jPanel1.add(jTextFieldMac5);
	jTextFieldMac5.setBounds(540, 50, 20, 21);
	jPanel1.add(jTextFieldMac6);
	jTextFieldMac6.setBounds(570, 50, 20, 21);

	jLabel9.setText(":");
	jPanel1.add(jLabel9);
	jLabel9.setBounds(440, 50, 10, 15);

	jLabel10.setText(":");
	jPanel1.add(jLabel10);
	jLabel10.setBounds(470, 50, 10, 15);

	jLabel11.setText(":");
	jPanel1.add(jLabel11);
	jLabel11.setBounds(500, 50, 10, 15);

	jLabel12.setText(":");
	jPanel1.add(jLabel12);
	jLabel12.setBounds(530, 50, 10, 15);

	jLabel13.setText(":");
	jPanel1.add(jLabel13);
	jLabel13.setBounds(560, 50, 10, 15);

	jPanelLocal.setBorder(BorderFactory.createTitledBorder("设备本地权限"));

	jCheckBoxLocalPlayback.setText("本地回放");

	jCheckBoxLoacalRecord.setText("本地录像");

	jCheckBoxLocalPTZ.setText("本地云台控制");

	jCheckBoxLocalBackup.setText("本地备份");

	jCheckBoxLocalState.setText("本地查看状态,日志");

	jCheckBoxLocalUpdate.setText("升级,格式化");

	jCheckBoxLocalSetPara.setText("本地设置参数");

	jCheckBoxLocalIPCamera.setText("本地IP接入配置");

	jCheckBoxLocalReboot.setText("本地重启,关机");

	jSeparator1.setOrientation(SwingConstants.VERTICAL);

	jLabel8.setText("权限类型");

	jComboBoxLocal.setModel(new DefaultComboBoxModel<Object>(new String[] {
		"本地回放", "本地录像", "云台控制", "本地备份" }));
	jComboBoxLocal.addActionListener(new java.awt.event.ActionListener() {
	    public void actionPerformed(java.awt.event.ActionEvent evt) {
		jComboBoxLocalActionPerformed(evt);
	    }
	});

	jScrollPane1.setViewportView(jListLocal);

	jButtonSaveLocal.setText("保存");
	jButtonSaveLocal.addActionListener(new java.awt.event.ActionListener() {
	    public void actionPerformed(java.awt.event.ActionEvent evt) {
		jButtonSaveLocalActionPerformed(evt);
	    }
	});

	GroupLayout jPanelLocalLayout = new GroupLayout(jPanelLocal);
	jPanelLocal.setLayout(jPanelLocalLayout);
	jPanelLocalLayout
		.setHorizontalGroup(jPanelLocalLayout
			.createParallelGroup(GroupLayout.Alignment.LEADING)
			.addGroup(
				jPanelLocalLayout
					.createSequentialGroup()
					.addGap(18, 18, 18)
					.addGroup(
						jPanelLocalLayout
							.createParallelGroup(
								GroupLayout.Alignment.LEADING)
							.addComponent(
								jCheckBoxLocalState)
							.addComponent(
								jCheckBoxLocalBackup)
							.addComponent(
								jCheckBoxLocalPTZ)
							.addComponent(
								jCheckBoxLocalPlayback)
							.addComponent(
								jCheckBoxLoacalRecord))
					.addGap(12, 12, 12)
					.addGroup(
						jPanelLocalLayout
							.createParallelGroup(
								GroupLayout.Alignment.LEADING)
							.addComponent(
								jCheckBoxLocalReboot)
							.addComponent(
								jCheckBoxLocalSetPara)
							.addComponent(
								jCheckBoxLocalUpdate)
							.addComponent(
								jCheckBoxLocalIPCamera))
					.addGap(20, 20, 20)
					.addComponent(jSeparator1,
						GroupLayout.PREFERRED_SIZE,
						GroupLayout.DEFAULT_SIZE,
						GroupLayout.PREFERRED_SIZE)
					.addGap(29, 29, 29)
					.addGroup(
						jPanelLocalLayout
							.createParallelGroup(
								GroupLayout.Alignment.LEADING)
							.addGroup(
								jPanelLocalLayout
									.createSequentialGroup()
									.addComponent(
										jLabel8,
										GroupLayout.PREFERRED_SIZE,
										56,
										GroupLayout.PREFERRED_SIZE)
									.addPreferredGap(
										LayoutStyle.ComponentPlacement.RELATED)
									.addComponent(
										jComboBoxLocal,
										GroupLayout.PREFERRED_SIZE,
										101,
										GroupLayout.PREFERRED_SIZE))
							.addGroup(
								jPanelLocalLayout
									.createSequentialGroup()
									.addComponent(
										jScrollPane1,
										GroupLayout.PREFERRED_SIZE,
										161,
										GroupLayout.PREFERRED_SIZE)
									.addGap(18,
										18,
										18)
									.addComponent(
										jButtonSaveLocal,
										GroupLayout.PREFERRED_SIZE,
										64,
										GroupLayout.PREFERRED_SIZE)))
					.addContainerGap(
						GroupLayout.DEFAULT_SIZE,
						Short.MAX_VALUE)));
	jPanelLocalLayout
		.setVerticalGroup(jPanelLocalLayout
			.createParallelGroup(GroupLayout.Alignment.LEADING)
			.addGroup(
				GroupLayout.Alignment.TRAILING,
				jPanelLocalLayout
					.createSequentialGroup()
					.addGroup(
						jPanelLocalLayout
							.createParallelGroup(
								GroupLayout.Alignment.TRAILING)
							.addComponent(
								jSeparator1,
								GroupLayout.Alignment.LEADING,
								GroupLayout.DEFAULT_SIZE,
								161,
								Short.MAX_VALUE)
							.addGroup(
								GroupLayout.Alignment.LEADING,
								jPanelLocalLayout
									.createSequentialGroup()
									.addComponent(
										jCheckBoxLocalPlayback)
									.addPreferredGap(
										LayoutStyle.ComponentPlacement.UNRELATED)
									.addComponent(
										jCheckBoxLoacalRecord)
									.addPreferredGap(
										LayoutStyle.ComponentPlacement.RELATED)
									.addComponent(
										jCheckBoxLocalPTZ)
									.addPreferredGap(
										LayoutStyle.ComponentPlacement.UNRELATED)
									.addComponent(
										jCheckBoxLocalBackup)
									.addPreferredGap(
										LayoutStyle.ComponentPlacement.UNRELATED)
									.addComponent(
										jCheckBoxLocalState))
							.addGroup(
								GroupLayout.Alignment.LEADING,
								jPanelLocalLayout
									.createSequentialGroup()
									.addGroup(
										jPanelLocalLayout
											.createParallelGroup(
												GroupLayout.Alignment.BASELINE)
											.addComponent(
												jLabel8)
											.addComponent(
												jComboBoxLocal,
												GroupLayout.PREFERRED_SIZE,
												GroupLayout.DEFAULT_SIZE,
												GroupLayout.PREFERRED_SIZE))
									.addPreferredGap(
										LayoutStyle.ComponentPlacement.RELATED)
									.addComponent(
										jScrollPane1,
										GroupLayout.DEFAULT_SIZE,
										134,
										Short.MAX_VALUE))
							.addGroup(
								GroupLayout.Alignment.LEADING,
								jPanelLocalLayout
									.createSequentialGroup()
									.addComponent(
										jCheckBoxLocalUpdate)
									.addPreferredGap(
										LayoutStyle.ComponentPlacement.UNRELATED)
									.addComponent(
										jCheckBoxLocalSetPara)
									.addPreferredGap(
										LayoutStyle.ComponentPlacement.RELATED)
									.addComponent(
										jCheckBoxLocalIPCamera)
									.addPreferredGap(
										LayoutStyle.ComponentPlacement.UNRELATED)
									.addComponent(
										jCheckBoxLocalReboot)
									.addPreferredGap(
										LayoutStyle.ComponentPlacement.RELATED,
										42,
										Short.MAX_VALUE)
									.addComponent(
										jButtonSaveLocal)))
					.addContainerGap()));

	jPanel1.add(jPanelLocal);
	jPanelLocal.setBounds(10, 80, 580, 200);

	jPanelRemote.setBorder(BorderFactory.createTitledBorder("客户端远程权限"));

	jCheckBoxRemotePlayback.setText("远程回放");

	jCheckBoxRemoteRealplay.setText("网络预览");

	jCheckBoxRemoteRecord.setText("远程手动录像");

	jCheckBoxRemotePTZ.setText("云台控制");

	jCheckBoxRemoteState.setText("查看状态,日志");

	jCheckBoxRemoteUpdate.setText("升级,格式化");

	jCheckBoxRemoteSerial.setText("远程控制串口");

	jCheckBoxRemoteAlarm.setText("报警上传,输出");

	jCheckBoxRemoteSetPara.setText("设置参数");

	jCheckBoxRemoteVoice.setText("语音对讲");

	jCheckBoxRemoteControl.setText("远程控制本地输出");

	jCheckBoxRemoteIPCamera.setText("远程IP接入配置");

	jCheckBoxRemoteReboot.setText("远程重启,关机");

	jSeparator2.setOrientation(SwingConstants.VERTICAL);

	jScrollPane2.setViewportView(jListRemote);

	jLabel14.setText("权限类型");

	jComboBoxRemote.setModel(new DefaultComboBoxModel<Object>(new String[] {
		"远程回放", "远程预览", "远程手动录像", "远程云台控制" }));
	jComboBoxRemote.addActionListener(new java.awt.event.ActionListener() {
	    public void actionPerformed(java.awt.event.ActionEvent evt) {
		jComboBoxRemoteActionPerformed(evt);
	    }
	});

	jButtonSaveRemote.setText("保存");
	jButtonSaveRemote
		.addActionListener(new java.awt.event.ActionListener() {
		    public void actionPerformed(java.awt.event.ActionEvent evt) {
			jButtonSaveRemoteActionPerformed(evt);
		    }
		});

	GroupLayout jPanelRemoteLayout = new GroupLayout(jPanelRemote);
	jPanelRemote.setLayout(jPanelRemoteLayout);
	jPanelRemoteLayout
		.setHorizontalGroup(jPanelRemoteLayout
			.createParallelGroup(GroupLayout.Alignment.LEADING)
			.addGroup(
				jPanelRemoteLayout
					.createSequentialGroup()
					.addGap(23, 23, 23)
					.addGroup(
						jPanelRemoteLayout
							.createParallelGroup(
								GroupLayout.Alignment.LEADING)
							.addComponent(
								jCheckBoxRemotePlayback)
							.addGroup(
								jPanelRemoteLayout
									.createParallelGroup(
										GroupLayout.Alignment.TRAILING)
									.addGroup(
										jPanelRemoteLayout
											.createParallelGroup(
												GroupLayout.Alignment.LEADING)
											.addComponent(
												jCheckBoxRemoteSerial)
											.addComponent(
												jCheckBoxRemoteAlarm)
											.addComponent(
												jCheckBoxRemoteUpdate))
									.addGroup(
										jPanelRemoteLayout
											.createParallelGroup(
												GroupLayout.Alignment.LEADING)
											.addComponent(
												jCheckBoxRemotePTZ)
											.addComponent(
												jCheckBoxRemoteState)
											.addComponent(
												jCheckBoxRemoteRecord)
											.addComponent(
												jCheckBoxRemoteRealplay))))
					.addGap(25, 25, 25)
					.addGroup(
						jPanelRemoteLayout
							.createParallelGroup(
								GroupLayout.Alignment.LEADING)
							.addComponent(
								jCheckBoxRemoteVoice)
							.addComponent(
								jCheckBoxRemoteSetPara)
							.addComponent(
								jCheckBoxRemoteControl)
							.addComponent(
								jCheckBoxRemoteIPCamera)
							.addComponent(
								jCheckBoxRemoteReboot))
					.addGap(18, 18, 18)
					.addComponent(jSeparator2,
						GroupLayout.PREFERRED_SIZE, 2,
						GroupLayout.PREFERRED_SIZE)
					.addGap(17, 17, 17)
					.addGroup(
						jPanelRemoteLayout
							.createParallelGroup(
								GroupLayout.Alignment.TRAILING)
							.addGroup(
								jPanelRemoteLayout
									.createSequentialGroup()
									.addComponent(
										jLabel14,
										GroupLayout.PREFERRED_SIZE,
										56,
										GroupLayout.PREFERRED_SIZE)
									.addPreferredGap(
										LayoutStyle.ComponentPlacement.RELATED)
									.addComponent(
										jComboBoxRemote,
										GroupLayout.PREFERRED_SIZE,
										101,
										GroupLayout.PREFERRED_SIZE))
							.addComponent(
								jScrollPane2,
								GroupLayout.PREFERRED_SIZE,
								162,
								GroupLayout.PREFERRED_SIZE))
					.addGap(18, 18, 18)
					.addComponent(jButtonSaveRemote,
						GroupLayout.DEFAULT_SIZE, 73,
						Short.MAX_VALUE)
					.addGap(10, 10, 10)));
	jPanelRemoteLayout
		.setVerticalGroup(jPanelRemoteLayout
			.createParallelGroup(GroupLayout.Alignment.LEADING)
			.addGroup(
				jPanelRemoteLayout
					.createSequentialGroup()
					.addComponent(jCheckBoxRemotePlayback)
					.addGap(2, 2, 2)
					.addComponent(jCheckBoxRemoteRealplay)
					.addGap(2, 2, 2)
					.addComponent(jCheckBoxRemoteRecord)
					.addGap(2, 2, 2)
					.addComponent(jCheckBoxRemotePTZ)
					.addPreferredGap(
						LayoutStyle.ComponentPlacement.RELATED)
					.addComponent(jCheckBoxRemoteState)
					.addPreferredGap(
						LayoutStyle.ComponentPlacement.UNRELATED)
					.addComponent(jCheckBoxRemoteUpdate)
					.addGap(2, 2, 2)
					.addComponent(jCheckBoxRemoteSerial)
					.addPreferredGap(
						LayoutStyle.ComponentPlacement.RELATED)
					.addComponent(jCheckBoxRemoteAlarm))
			.addGroup(
				jPanelRemoteLayout
					.createSequentialGroup()
					.addGroup(
						jPanelRemoteLayout
							.createParallelGroup(
								GroupLayout.Alignment.BASELINE)
							.addComponent(
								jComboBoxRemote,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.DEFAULT_SIZE,
								GroupLayout.PREFERRED_SIZE)
							.addComponent(jLabel14))
					.addPreferredGap(
						LayoutStyle.ComponentPlacement.RELATED)
					.addComponent(jScrollPane2,
						GroupLayout.DEFAULT_SIZE, 174,
						Short.MAX_VALUE))
			.addGroup(
				GroupLayout.Alignment.TRAILING,
				jPanelRemoteLayout
					.createSequentialGroup()
					.addComponent(jCheckBoxRemoteSetPara)
					.addGap(2, 2, 2)
					.addComponent(jCheckBoxRemoteVoice)
					.addGap(2, 2, 2)
					.addComponent(jCheckBoxRemoteControl)
					.addGap(2, 2, 2)
					.addComponent(jCheckBoxRemoteIPCamera)
					.addPreferredGap(
						LayoutStyle.ComponentPlacement.RELATED)
					.addComponent(jCheckBoxRemoteReboot)
					.addPreferredGap(
						LayoutStyle.ComponentPlacement.RELATED,
						57, Short.MAX_VALUE)
					.addComponent(jButtonSaveRemote))
			.addComponent(jSeparator2, GroupLayout.DEFAULT_SIZE,
				201, Short.MAX_VALUE));

	jPanel1.add(jPanelRemote);
	jPanelRemote.setBounds(10, 280, 580, 230);

	jButtonSaveUser.setText("保存");
	jButtonSaveUser.addActionListener(new java.awt.event.ActionListener() {
	    public void actionPerformed(java.awt.event.ActionEvent evt) {
		jButtonSaveUserActionPerformed(evt);
	    }
	});
	jPanel1.add(jButtonSaveUser);
	jButtonSaveUser.setBounds(20, 520, 81, 23);

	jButtonSetup.setText("设置");
	jButtonSetup.addActionListener(new java.awt.event.ActionListener() {
	    public void actionPerformed(java.awt.event.ActionEvent evt) {
		jButtonSetupActionPerformed(evt);
	    }
	});

	jButtonExit.setText("退出");
	jButtonExit.addActionListener(new java.awt.event.ActionListener() {
	    public void actionPerformed(java.awt.event.ActionEvent evt) {
		jButtonExitActionPerformed(evt);
	    }
	});

	jButtonUPdate.setText("刷新");
	jButtonUPdate.addActionListener(new java.awt.event.ActionListener() {
	    public void actionPerformed(java.awt.event.ActionEvent evt) {
		jButtonUPdateActionPerformed(evt);
	    }
	});

	GroupLayout layout = new GroupLayout(getContentPane());
	getContentPane().setLayout(layout);
	layout.setHorizontalGroup(layout
		.createParallelGroup(GroupLayout.Alignment.LEADING)
		.addGroup(
			layout.createSequentialGroup()
				.addContainerGap()
				.addComponent(jPanel1,
					GroupLayout.PREFERRED_SIZE, 604,
					GroupLayout.PREFERRED_SIZE)
				.addContainerGap(GroupLayout.DEFAULT_SIZE,
					Short.MAX_VALUE))
		.addGroup(
			layout.createSequentialGroup()
				.addGap(33, 33, 33)
				.addComponent(jButtonSetup,
					GroupLayout.PREFERRED_SIZE, 72,
					GroupLayout.PREFERRED_SIZE)
				.addGap(44, 44, 44)
				.addComponent(jButtonUPdate,
					GroupLayout.PREFERRED_SIZE, 65,
					GroupLayout.PREFERRED_SIZE)
				.addPreferredGap(
					LayoutStyle.ComponentPlacement.RELATED,
					281, Short.MAX_VALUE)
				.addComponent(jButtonExit,
					GroupLayout.PREFERRED_SIZE, 75,
					GroupLayout.PREFERRED_SIZE)
				.addGap(54, 54, 54)));
	layout.setVerticalGroup(layout.createParallelGroup(
		GroupLayout.Alignment.LEADING).addGroup(
		layout.createSequentialGroup()
			.addContainerGap()
			.addComponent(jPanel1, GroupLayout.PREFERRED_SIZE, 555,
				GroupLayout.PREFERRED_SIZE)
			.addPreferredGap(
				LayoutStyle.ComponentPlacement.RELATED, 12,
				Short.MAX_VALUE)
			.addGroup(
				layout.createParallelGroup(
					GroupLayout.Alignment.BASELINE)
					.addComponent(jButtonSetup)
					.addComponent(jButtonExit)
					.addComponent(jButtonUPdate))
			.addContainerGap()));

	pack();
    }// </editor-fold>//GEN-END:initComponents

    /*************************************************
     * 函数: "退出" 按钮单击响应函数 函数描述: 销毁对话框
     *************************************************/
    private void jButtonExitActionPerformed(java.awt.event.ActionEvent evt)// GEN-FIRST:event_jButtonExitActionPerformed
    {// GEN-HEADEREND:event_jButtonExitActionPerformed
	dispose();
    }// GEN-LAST:event_jButtonExitActionPerformed

    /*************************************************
     * 函数: "用户" 组合框选项改变响应函数 函数描述: 显示所选用户的参数
     *************************************************/
    private void jComboBoxUserActionPerformed(java.awt.event.ActionEvent evt)// GEN-FIRST:event_jComboBoxUserActionPerformed
    {// GEN-HEADEREND:event_jComboBoxUserActionPerformed
	if (bInitialed) {
	    showSingleUser();
	}
    }// GEN-LAST:event_jComboBoxUserActionPerformed

    /*************************************************
     * 函数: 本地 "权限类型" 组合框选项改变响应函数 函数描述: 显示对应的权限参数
     *************************************************/
    private void jComboBoxLocalActionPerformed(java.awt.event.ActionEvent evt)// GEN-FIRST:event_jComboBoxLocalActionPerformed
    {// GEN-HEADEREND:event_jComboBoxLocalActionPerformed
	if (bInitialed) {
	    showLocalChannel();
	}
    }// GEN-LAST:event_jComboBoxLocalActionPerformed

    /*************************************************
     * 函数: 远程 "权限类型" 组合框选项改变响应函数 函数描述: 显示对应的权限参数
     *************************************************/
    private void jComboBoxRemoteActionPerformed(java.awt.event.ActionEvent evt)// GEN-FIRST:event_jComboBoxRemoteActionPerformed
    {// GEN-HEADEREND:event_jComboBoxRemoteActionPerformed
	if (bInitialed) {
	    showRemoteChannel();
	}
    }// GEN-LAST:event_jComboBoxRemoteActionPerformed

    /*************************************************
     * 函数: 本地权限类型 "保存"按钮单击响应函数 函数描述: 保存权限类型对应通道参数
     *************************************************/
    private void jButtonSaveLocalActionPerformed(java.awt.event.ActionEvent evt)// GEN-FIRST:event_jButtonSaveLocalActionPerformed
    {// GEN-HEADEREND:event_jButtonSaveLocalActionPerformed
	m_iUserIndex = jComboBoxUser.getSelectedIndex();
	int iRightType = jComboBoxLocal.getSelectedIndex();
	switch (iRightType) {
	case 0:// 本地回放
	    for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++) {
		m_struUserCfg.struUser[m_iUserIndex].byLocalPlaybackRight[i] = (byte) (m_LocalChannel[i]
			.getCheck() ? 1 : 0);
	    }
	    break;
	case 1:// 本地录像
	    for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++) {
		m_struUserCfg.struUser[m_iUserIndex].byLocalRecordRight[i] = (byte) (m_LocalChannel[i]
			.getCheck() ? 1 : 0);
	    }
	    break;
	case 2:// 云台控制
	    for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++) {
		m_struUserCfg.struUser[m_iUserIndex].byLocalPTZRight[i] = (byte) (m_LocalChannel[i]
			.getCheck() ? 1 : 0);
	    }
	    break;
	case 3:// 本地备份
	    for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++) {
		m_struUserCfg.struUser[m_iUserIndex].byLocalBackupRight[i] = (byte) (m_LocalChannel[i]
			.getCheck() ? 1 : 0);
	    }
	    break;
	}
    }// GEN-LAST:event_jButtonSaveLocalActionPerformed

    /*************************************************
     * 函数: 远程权限类型 "保存"按钮单击响应函数 函数描述: 保存权限类型对应通道参数
     *************************************************/
    private void jButtonSaveRemoteActionPerformed(java.awt.event.ActionEvent evt)// GEN-FIRST:event_jButtonSaveRemoteActionPerformed
    {// GEN-HEADEREND:event_jButtonSaveRemoteActionPerformed
	m_iUserIndex = jComboBoxUser.getSelectedIndex();
	int iRightType = jComboBoxRemote.getSelectedIndex();
	switch (iRightType) {
	case 0:// 本地回放
	    for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++) {
		m_struUserCfg.struUser[m_iUserIndex].byNetPlaybackRight[i] = (byte) (m_RemoteChannel[i]
			.getCheck() ? 1 : 0);
	    }
	    break;
	case 1:// 本地录像
	    for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++) {
		m_struUserCfg.struUser[m_iUserIndex].byNetPreviewRight[i] = (byte) (m_RemoteChannel[i]
			.getCheck() ? 1 : 0);
	    }
	    break;
	case 2:// 云台控制
	    for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++) {
		m_struUserCfg.struUser[m_iUserIndex].byNetRecordRight[i] = (byte) (m_RemoteChannel[i]
			.getCheck() ? 1 : 0);
	    }
	    break;
	case 3:// 本地备份
	    for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++) {
		m_struUserCfg.struUser[m_iUserIndex].byNetPTZRight[i] = (byte) (m_RemoteChannel[i]
			.getCheck() ? 1 : 0);
	    }
	    break;
	}
    }// GEN-LAST:event_jButtonSaveRemoteActionPerformed

    /*************************************************
     * 函数: 全局 "保存" 按钮单击响应函数 函数描述: 保存用户名 密码 优先级 IP Mac地址 权限等参数至结构体
     *************************************************/
    private void jButtonSaveUserActionPerformed(java.awt.event.ActionEvent evt)// GEN-FIRST:event_jButtonSaveUserActionPerformed
    {// GEN-HEADEREND:event_jButtonSaveUserActionPerformed
	m_iUserIndex = jComboBoxUser.getSelectedIndex();

	// 用户名
	m_struUserCfg.struUser[m_iUserIndex].sUserName = new String(
		jTextFieldUserName.getText() + "\0").getBytes();

	// 密码
	if (new String(jPasswordFieldPassword.getPassword()).equals(new String(
		jPasswordFieldPassConfirm.getPassword()))) {
	    m_struUserCfg.struUser[m_iUserIndex].sPassword = new String(
		    jPasswordFieldPassword.getPassword().toString() + "\0")
		    .getBytes();
	} else {
	    JOptionPane.showMessageDialog(this, "密码与确认密码不一致");
	    System.out.println(jPasswordFieldPassword.getPassword());
	    System.out.println(jPasswordFieldPassConfirm.getPassword());
	    return;
	}

	// 优先级
	m_struUserCfg.struUser[m_iUserIndex].byPriority = (byte) jComboBoxPriority
		.getSelectedIndex();

	// 允许IP
	m_struUserCfg.struUser[m_iUserIndex].struUserIP.sIpV4 = new String(
		jTextFieldUserIP.getText() + "\0").getBytes();

	// 允许mac地址
	m_struUserCfg.struUser[m_iUserIndex].byMACAddr[0] = (byte) Integer
		.parseInt(jTextFieldMac1.getText(), 16);
	m_struUserCfg.struUser[m_iUserIndex].byMACAddr[1] = (byte) Integer
		.parseInt(jTextFieldMac2.getText(), 16);
	m_struUserCfg.struUser[m_iUserIndex].byMACAddr[2] = (byte) Integer
		.parseInt(jTextFieldMac3.getText(), 16);
	m_struUserCfg.struUser[m_iUserIndex].byMACAddr[3] = (byte) Integer
		.parseInt(jTextFieldMac4.getText(), 16);
	m_struUserCfg.struUser[m_iUserIndex].byMACAddr[4] = (byte) Integer
		.parseInt(jTextFieldMac5.getText(), 16);
	m_struUserCfg.struUser[m_iUserIndex].byMACAddr[5] = (byte) Integer
		.parseInt(jTextFieldMac6.getText(), 16);

	// 本地操作权限
	m_struUserCfg.struUser[m_iUserIndex].byLocalRight[0] = (byte) (jCheckBoxLocalPTZ
		.isSelected() ? 1 : 0);
	m_struUserCfg.struUser[m_iUserIndex].byLocalRight[1] = (byte) (jCheckBoxLoacalRecord
		.isSelected() ? 1 : 0);
	m_struUserCfg.struUser[m_iUserIndex].byLocalRight[2] = (byte) (jCheckBoxLocalPlayback
		.isSelected() ? 1 : 0);
	m_struUserCfg.struUser[m_iUserIndex].byLocalRight[3] = (byte) (jCheckBoxLocalSetPara
		.isSelected() ? 1 : 0);
	m_struUserCfg.struUser[m_iUserIndex].byLocalRight[4] = (byte) (jCheckBoxLocalState
		.isSelected() ? 1 : 0);
	m_struUserCfg.struUser[m_iUserIndex].byLocalRight[5] = (byte) (jCheckBoxLocalUpdate
		.isSelected() ? 1 : 0);
	m_struUserCfg.struUser[m_iUserIndex].byLocalRight[7] = (byte) (jCheckBoxLocalIPCamera
		.isSelected() ? 1 : 0);
	m_struUserCfg.struUser[m_iUserIndex].byLocalRight[8] = (byte) (jCheckBoxLocalBackup
		.isSelected() ? 1 : 0);
	m_struUserCfg.struUser[m_iUserIndex].byLocalRight[9] = (byte) (jCheckBoxLocalReboot
		.isSelected() ? 1 : 0);

	// 远程操作权限
	m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[0] = (byte) (jCheckBoxRemotePTZ
		.isSelected() ? 1 : 0);
	m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[1] = (byte) (jCheckBoxRemoteRecord
		.isSelected() ? 1 : 0);
	m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[2] = (byte) (jCheckBoxRemotePlayback
		.isSelected() ? 1 : 0);
	m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[3] = (byte) (jCheckBoxRemoteSetPara
		.isSelected() ? 1 : 0);
	m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[4] = (byte) (jCheckBoxRemoteState
		.isSelected() ? 1 : 0);
	m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[5] = (byte) (jCheckBoxRemoteUpdate
		.isSelected() ? 1 : 0);
	m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[6] = (byte) (jCheckBoxRemoteVoice
		.isSelected() ? 1 : 0);
	m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[7] = (byte) (jCheckBoxRemoteRealplay
		.isSelected() ? 1 : 0);
	m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[8] = (byte) (jCheckBoxRemoteAlarm
		.isSelected() ? 1 : 0);
	m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[9] = (byte) (jCheckBoxRemoteControl
		.isSelected() ? 1 : 0);
	m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[10] = (byte) (jCheckBoxRemoteSerial
		.isSelected() ? 1 : 0);
	m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[12] = (byte) (jCheckBoxRemoteIPCamera
		.isSelected() ? 1 : 0);
	m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[13] = (byte) (jCheckBoxRemoteReboot
		.isSelected() ? 1 : 0);

    }// GEN-LAST:event_jButtonSaveUserActionPerformed

    /*************************************************
     * 函数: "设置" 按钮单击响应函数 函数描述: 调用接口设置参数至设备
     *************************************************/
    private void jButtonSetupActionPerformed(java.awt.event.ActionEvent evt)// GEN-FIRST:event_jButtonSetupActionPerformed
    {// GEN-HEADEREND:event_jButtonSetupActionPerformed
	m_struUserCfg.write();
	Pointer lpConfig = m_struUserCfg.getPointer();
	boolean setDVRConfigSuc = hCNetSDK.NET_DVR_SetDVRConfig(m_lUserID,
		HCNetSDK.NET_DVR_SET_USERCFG_V30, new NativeLong(0), lpConfig,
		m_struUserCfg.size());
	m_struUserCfg.read();
	if (setDVRConfigSuc != true) {
	    JOptionPane.showMessageDialog(this, "设置用户参数失败");
	    return;
	} else {
	    JOptionPane.showMessageDialog(this, "设置用户参数成功");
	}
    }// GEN-LAST:event_jButtonSetupActionPerformed

    /*************************************************
     * 函数: "刷新" 按钮单击响应函数 函数描述: 重新从设备获取参数并显示
     *************************************************/
    private void jButtonUPdateActionPerformed(java.awt.event.ActionEvent evt)// GEN-FIRST:event_jButtonUPdateActionPerformed
    {// GEN-HEADEREND:event_jButtonUPdateActionPerformed
	m_struUserCfg = new HCNetSDK.NET_DVR_USER_V30();
	m_struUserCfg.write();
	Pointer lpPicConfig = m_struUserCfg.getPointer();
	boolean getDVRConfigSuc = hCNetSDK.NET_DVR_GetDVRConfig(m_lUserID,
		HCNetSDK.NET_DVR_GET_USERCFG_V30, new NativeLong(0),
		lpPicConfig, m_struUserCfg.size(), new IntByReference(0));
	m_struUserCfg.read();
	if (getDVRConfigSuc == false) {
	    JOptionPane.showMessageDialog(this, "获取用户配置信息失败!");
	    return;
	}
	// 显示的第一个用户也就是超级用户
	jComboBoxUser.setSelectedIndex(0);
    }// GEN-LAST:event_jButtonUPdateActionPerformed

    /*************************************************
     * 函数: initialDialog 函数描述: 初始化对话框,获取参数,显示第一个用户的参数
     *************************************************/
    private void initialDialog() {
	// 起始通道号
	int iStartChan = m_strDeviceInfo.byStartChan;
	// 模拟通道数
	int iChannum = m_strDeviceInfo.byChanNum;

	// 先将每个checkbox初始化,便于以后赋值,不显示的也初始化
	for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++) {
	    m_LocalChannel[i] = new CheckListItem(false, " ");
	    m_RemoteChannel[i] = new CheckListItem(false, " ");
	}

	// 设备本地权限通道list初始化
	jListLocal.setCellRenderer(new CheckListItemRenderer());
	DefaultListModel<CheckListItem> listModelLocal = new DefaultListModel<CheckListItem>();
	jListLocal.setModel(listModelLocal);
	jListLocal.addMouseListener(new CheckListMouseListener());

	for (int i = 0; i < iChannum; i++) {
	    m_LocalChannel[i] = new CheckListItem(false, "Camera"
		    + (i + iStartChan));
	    listModelLocal.addElement(m_LocalChannel[i]);
	}
	for (int i = 0; i < HCNetSDK.MAX_IP_CHANNEL; i++) {
	    if (m_strIpparaCfg.struIPChanInfo[i].byEnable == 1) {
		m_LocalChannel[i + 32] = new CheckListItem(false, "IPCamara"
			+ (i + iStartChan));
		listModelLocal.addElement(m_LocalChannel[i + 32]);
	    }
	}

	// 设备远程权限通道list初始化
	jListRemote.setCellRenderer(new CheckListItemRenderer());
	DefaultListModel<CheckListItem> listModelRemote = new DefaultListModel<CheckListItem>();
	jListRemote.setModel(listModelRemote);
	jListRemote.addMouseListener(new CheckListMouseListener());

	for (int i = 0; i < iChannum; i++) {
	    m_RemoteChannel[i] = new CheckListItem(false, "Camera"
		    + (i + iStartChan));
	    listModelRemote.addElement(m_RemoteChannel[i]);
	}
	for (int i = 0; i < HCNetSDK.MAX_IP_CHANNEL; i++) {
	    if (m_strIpparaCfg.struIPChanInfo[i].byEnable == 1) {
		m_RemoteChannel[i + 32] = new CheckListItem(false, "IPCamara"
			+ (i + iStartChan));
		listModelRemote.addElement(m_RemoteChannel[i + 32]);
	    }
	}

	m_struUserCfg = new HCNetSDK.NET_DVR_USER_V30();
	m_struUserCfg.write();
	Pointer lpPicConfig = m_struUserCfg.getPointer();
	boolean getDVRConfigSuc = hCNetSDK.NET_DVR_GetDVRConfig(m_lUserID,
		HCNetSDK.NET_DVR_GET_USERCFG_V30, new NativeLong(0),
		lpPicConfig, m_struUserCfg.size(), new IntByReference(0));
	m_struUserCfg.read();
	if (getDVRConfigSuc == false) {
	    JOptionPane.showMessageDialog(this, "获取用户配置信息失败!");
	    return;
	}
	// 初始化时显示的第一个用户也就是超级用户
	jComboBoxUser.setSelectedIndex(0);
	showSingleUser();

	bInitialed = true;
    }

    /*************************************************
     * 函数: showSingleUser 函数描述: 显示单个用户的参数
     *************************************************/
    private void showSingleUser() {
	m_iUserIndex = jComboBoxUser.getSelectedIndex();

	String[] s = new String[2];
	// 用户名
	s = new String(m_struUserCfg.struUser[m_iUserIndex].sUserName).split(
		"\0", 2);
	jTextFieldUserName.setText(s[0]);
	// 密码
	s = new String(m_struUserCfg.struUser[m_iUserIndex].sPassword).split(
		"\0", 2);
	jPasswordFieldPassword.setText(s[0]);
	// 确认密码
	jPasswordFieldPassConfirm.setText(s[0]);
	// 优先级
	if (m_iUserIndex == 0) {
	    jComboBoxPriority.setSelectedIndex(2);
	} else {
	    jComboBoxPriority
		    .setSelectedIndex(m_struUserCfg.struUser[m_iUserIndex].byPriority);
	}
	// 允许IP
	s = new String(m_struUserCfg.struUser[m_iUserIndex].struUserIP.sIpV4)
		.split("\0", 2);
	jTextFieldUserIP.setText(s[0]);
	// 允许mac地址
	jTextFieldMac1.setText(String.format("%02x",
		m_struUserCfg.struUser[m_iUserIndex].byMACAddr[0]));
	jTextFieldMac2.setText(String.format("%02x",
		m_struUserCfg.struUser[m_iUserIndex].byMACAddr[1]));
	jTextFieldMac3.setText(String.format("%02x",
		m_struUserCfg.struUser[m_iUserIndex].byMACAddr[2]));
	jTextFieldMac4.setText(String.format("%02x",
		m_struUserCfg.struUser[m_iUserIndex].byMACAddr[3]));
	jTextFieldMac5.setText(String.format("%02x",
		m_struUserCfg.struUser[m_iUserIndex].byMACAddr[4]));
	jTextFieldMac6.setText(String.format("%02x",
		m_struUserCfg.struUser[m_iUserIndex].byMACAddr[5]));

	// 本地操作权限
	jCheckBoxLocalPTZ
		.setSelected(m_struUserCfg.struUser[m_iUserIndex].byLocalRight[0] == 1);
	jCheckBoxLoacalRecord
		.setSelected(m_struUserCfg.struUser[m_iUserIndex].byLocalRight[1] == 1);
	jCheckBoxLocalPlayback
		.setSelected(m_struUserCfg.struUser[m_iUserIndex].byLocalRight[2] == 1);
	jCheckBoxLocalSetPara
		.setSelected(m_struUserCfg.struUser[m_iUserIndex].byLocalRight[3] == 1);
	jCheckBoxLocalState
		.setSelected(m_struUserCfg.struUser[m_iUserIndex].byLocalRight[4] == 1);
	jCheckBoxLocalUpdate
		.setSelected(m_struUserCfg.struUser[m_iUserIndex].byLocalRight[5] == 1);
	jCheckBoxLocalIPCamera
		.setSelected(m_struUserCfg.struUser[m_iUserIndex].byLocalRight[7] == 1);
	jCheckBoxLocalBackup
		.setSelected(m_struUserCfg.struUser[m_iUserIndex].byLocalRight[8] == 1);
	jCheckBoxLocalReboot
		.setSelected(m_struUserCfg.struUser[m_iUserIndex].byLocalRight[9] == 1);

	jComboBoxLocal.setSelectedIndex(0);
	showLocalChannel();

	// 远程操作权限
	jCheckBoxRemotePTZ
		.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[0] == 1);
	jCheckBoxRemoteRecord
		.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[1] == 1);
	jCheckBoxRemotePlayback
		.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[2] == 1);
	jCheckBoxRemoteSetPara
		.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[3] == 1);
	jCheckBoxRemoteState
		.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[4] == 1);
	jCheckBoxRemoteUpdate
		.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[5] == 1);
	jCheckBoxRemoteVoice
		.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[6] == 1);
	jCheckBoxRemoteRealplay
		.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[7] == 1);
	jCheckBoxRemoteAlarm
		.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[8] == 1);
	jCheckBoxRemoteControl
		.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[9] == 1);
	jCheckBoxRemoteSerial
		.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[10] == 1);
	jCheckBoxRemoteIPCamera
		.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[12] == 1);
	jCheckBoxRemoteReboot
		.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[13] == 1);

	jComboBoxRemote.setSelectedIndex(0);
	showRemoteChannel();

	// 超级用户
	if (m_iUserIndex == 0) {
	    setEnable(false);
	} else {
	    setEnable(true);
	}
    }

    /*************************************************
     * 函数: showLocalChannel 函数描述: 显示本地某个权限对应的通道
     *************************************************/
    private void showLocalChannel() {
	int iRightType = jComboBoxLocal.getSelectedIndex();
	switch (iRightType) {
	case 0:// 本地回放
	    for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++) {
		m_LocalChannel[i]
			.setCheck(m_struUserCfg.struUser[m_iUserIndex].byLocalPlaybackRight[i] == 1);
	    }
	    break;
	case 1:// 本地录像
	    for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++) {
		m_LocalChannel[i]
			.setCheck(m_struUserCfg.struUser[m_iUserIndex].byLocalRecordRight[i] == 1);
	    }
	    break;
	case 2:// 云台控制
	    for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++) {
		m_LocalChannel[i]
			.setCheck(m_struUserCfg.struUser[m_iUserIndex].byLocalPTZRight[i] == 1);
	    }
	    break;
	case 3:// 本地备份
	    for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++) {
		m_LocalChannel[i]
			.setCheck(m_struUserCfg.struUser[m_iUserIndex].byLocalBackupRight[i] == 1);
	    }
	    break;
	}
	jListLocal.repaint();
    }

    /*************************************************
     * 函数: showRemoteChannel 函数描述: 显示远程某个权限对应的通道
     *************************************************/
    private void showRemoteChannel() {
	int iRightType = jComboBoxRemote.getSelectedIndex();
	switch (iRightType) {
	case 0:// 远程回放
	    for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++) {
		m_RemoteChannel[i]
			.setCheck(m_struUserCfg.struUser[m_iUserIndex].byNetPlaybackRight[i] == 1);
	    }
	    break;
	case 1:// 远程预览
	    for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++) {
		m_RemoteChannel[i]
			.setCheck(m_struUserCfg.struUser[m_iUserIndex].byNetPreviewRight[i] == 1);
	    }
	    break;
	case 2:// 远程手动录像
	    for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++) {
		m_RemoteChannel[i]
			.setCheck(m_struUserCfg.struUser[m_iUserIndex].byNetRecordRight[i] == 1);
	    }
	    break;
	case 3:// 远程云台控制
	    for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++) {
		m_RemoteChannel[i]
			.setCheck(m_struUserCfg.struUser[m_iUserIndex].byNetPTZRight[i] == 1);
	    }
	    break;
	}
	jListRemote.repaint();
    }

    /*************************************************
     * 函数: setEnable 函数描述: 设置控件可编辑性
     *************************************************/
    private void setEnable(boolean bEbnable) {
	jTextFieldUserName.setEnabled(bEbnable);
	jComboBoxPriority.setEnabled(bEbnable);
	jCheckBoxLocalPTZ.setEnabled(bEbnable);
	jCheckBoxLoacalRecord.setEnabled(bEbnable);
	jCheckBoxLocalPlayback.setEnabled(bEbnable);
	jCheckBoxLocalSetPara.setEnabled(bEbnable);
	jCheckBoxLocalState.setEnabled(bEbnable);
	jCheckBoxLocalUpdate.setEnabled(bEbnable);
	jCheckBoxLocalIPCamera.setEnabled(bEbnable);
	jCheckBoxLocalBackup.setEnabled(bEbnable);
	jCheckBoxLocalReboot.setEnabled(bEbnable);

	jCheckBoxRemotePTZ.setEnabled(bEbnable);
	jCheckBoxRemoteRecord.setEnabled(bEbnable);
	jCheckBoxRemotePlayback.setEnabled(bEbnable);
	jCheckBoxRemoteSetPara.setEnabled(bEbnable);
	jCheckBoxRemoteState.setEnabled(bEbnable);
	jCheckBoxRemoteUpdate.setEnabled(bEbnable);
	jCheckBoxRemoteVoice.setEnabled(bEbnable);
	jCheckBoxRemoteRealplay.setEnabled(bEbnable);
	jCheckBoxRemoteAlarm.setEnabled(bEbnable);
	jCheckBoxRemoteControl.setEnabled(bEbnable);
	jCheckBoxRemoteSerial.setEnabled(bEbnable);
	jCheckBoxRemoteIPCamera.setEnabled(bEbnable);
	jCheckBoxRemoteReboot.setEnabled(bEbnable);
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private JButton jButtonExit;
    private JButton jButtonSaveLocal;
    private JButton jButtonSaveRemote;
    private JButton jButtonSaveUser;
    private JButton jButtonSetup;
    private JButton jButtonUPdate;
    private JCheckBox jCheckBoxLoacalRecord;
    private JCheckBox jCheckBoxLocalBackup;
    private JCheckBox jCheckBoxLocalIPCamera;
    private JCheckBox jCheckBoxLocalPTZ;
    private JCheckBox jCheckBoxLocalPlayback;
    private JCheckBox jCheckBoxLocalReboot;
    private JCheckBox jCheckBoxLocalSetPara;
    private JCheckBox jCheckBoxLocalState;
    private JCheckBox jCheckBoxLocalUpdate;
    private JCheckBox jCheckBoxRemoteAlarm;
    private JCheckBox jCheckBoxRemoteControl;
    private JCheckBox jCheckBoxRemoteIPCamera;
    private JCheckBox jCheckBoxRemotePTZ;
    private JCheckBox jCheckBoxRemotePlayback;
    private JCheckBox jCheckBoxRemoteRealplay;
    private JCheckBox jCheckBoxRemoteReboot;
    private JCheckBox jCheckBoxRemoteRecord;
    private JCheckBox jCheckBoxRemoteSerial;
    private JCheckBox jCheckBoxRemoteSetPara;
    private JCheckBox jCheckBoxRemoteState;
    private JCheckBox jCheckBoxRemoteUpdate;
    private JCheckBox jCheckBoxRemoteVoice;
    private JComboBox<Object> jComboBoxLocal;
    private JComboBox<Object> jComboBoxPriority;
    private JComboBox<Object> jComboBoxRemote;
    private JComboBox<Object> jComboBoxUser;
    private JLabel jLabel1;
    private JLabel jLabel10;
    private JLabel jLabel11;
    private JLabel jLabel12;
    private JLabel jLabel13;
    private JLabel jLabel14;
    private JLabel jLabel2;
    private JLabel jLabel3;
    private JLabel jLabel4;
    private JLabel jLabel5;
    private JLabel jLabel6;
    private JLabel jLabel7;
    private JLabel jLabel8;
    private JLabel jLabel9;
    private JList<CheckListItem> jListLocal;
    private JList<CheckListItem> jListRemote;
    private JPanel jPanel1;
    private JPanel jPanelLocal;
    private JPanel jPanelRemote;
    private JPasswordField jPasswordFieldPassConfirm;
    private JPasswordField jPasswordFieldPassword;
    private JScrollPane jScrollPane1;
    private JScrollPane jScrollPane2;
    private JSeparator jSeparator1;
    private JSeparator jSeparator2;
    private JTextField jTextFieldMac1;
    private JTextField jTextFieldMac2;
    private JTextField jTextFieldMac3;
    private JTextField jTextFieldMac4;
    private JTextField jTextFieldMac5;
    private JTextField jTextFieldMac6;
    private JTextField jTextFieldUserIP;
    private JTextField jTextFieldUserName;

    // End of variables declaration//GEN-END:variables

    /******************************************************************************
     * 类: CheckListItemRenderer JCheckBox ListCellRenderer
     ******************************************************************************/
    public class CheckListItemRenderer extends JCheckBox implements
	    ListCellRenderer<Object> {

	private static final long serialVersionUID = 1000122L;

	public Component getListCellRendererComponent(
		@SuppressWarnings("rawtypes") JList list, Object value,
		int index, boolean isSelected, boolean cellHasFocus) {
	    CheckListItem item = (CheckListItem) value;
	    this.setSelected(item.getCheck());
	    this.setText(item.getText());
	    this.setFont(list.getFont());
	    this.setEnabled(list.isEnabled());
	    return this;
	}
    }

    /******************************************************************************
     * 类: CheckListItem
     * 
     ******************************************************************************/
    public class CheckListItem {

	boolean check;
	String text;

	public CheckListItem(boolean check, String text) {
	    this.check = check;
	    this.text = text;
	}

	public boolean getCheck() {
	    return check;
	}

	public void setCheck(boolean _check) {
	    check = _check;
	}

	public String getText() {
	    return text;
	}

	public void setText(String _text) {
	    text = _text;
	}
    }

    /******************************************************************************
     * 类: CheckListMouseListener
     * 
     ******************************************************************************/
    class CheckListMouseListener extends MouseAdapter {

	public void mousePressed(MouseEvent e) {
	    @SuppressWarnings("unchecked")
	    JList<Object> list = (JList<Object>) e.getSource();
	    int index = list.locationToIndex(e.getPoint());
	    CheckListItem item = (CheckListItem) list.getModel().getElementAt(
		    index);
	    item.setCheck(!item.getCheck());
	    Rectangle rect = list.getCellBounds(index, index);
	    list.repaint(rect);
	}
    }
}
